package com.macaline.technology.webService;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;

import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.rmi.RemoteException;

public class Client {
    public static void main(String[] args) throws ServiceException, RemoteException, UnsupportedEncodingException {
        byte[] flag;//(byte)0
        String xml= "";
        Object privateKey = "";
//        byte[] signature = SignatureHelper.sign(privateKey, xml);//采用私钥签名报文，签名内容只是
//        byte[] signature;//采用私钥签名报文，签名内容只是
        try {
            Service service = new Service();
            Call call = (Call) service.createCall();
            call.setTargetEndpointAddress("http://localhost:8085/ws_server/weather");
            call.setOperationName(new QName("weatherService", "getWeather"));
            call.addParameter("cityName", XMLType.XSD_BYTE, ParameterMode.IN);
            call.setReturnType(XMLType.XSD_BASE64);//设置返回类型

            Object[] params =new Object[]{"jinan"};
            byte[] retData = (byte[]) call.invoke(params);
            System.out.println(new String(retData, StandardCharsets.UTF_8));
        }
        catch (ServiceException | RemoteException se)
        {
            throw se;
        }
    }
}
